/******************************************************************************************
 * Import
 ******************************************************************************************/

// module
import Taro, { Component } from '@tarojs/taro'
import { Swiper } from '@tarojs/components'

// project
import { CPage, CContent, CHeader, CFooter, CFloat, CAround, CBetween, CCenter, CRow, CWrap, CLine, CHand, CItemX, CItemY, CText, CLabel, CSvg, CImage, CButton } from '../../library/comp';
import { Base64, Gen, Time, Zip, Session, Storage, Http } from '../../library/func';
import Icon from '../../project/style/icon';

import DoHttp from '../../project/func/http/http';

/******************************************************************************************
 * Export Class
 ******************************************************************************************/

export default class Detail extends Component {

	/*------------------------------------------------------------------------------------
	 * 初始化
	 *-----------------------------------------------------------------------------------*/
	constructor(props) {
		super(props);
	}

	/*------------------------------------------------------------------------------------
	 * 生命周期
	 *-----------------------------------------------------------------------------------*/
	// didMount
	componentDidMount() {

	}
	
	/*------------------------------------------------------------------------------------
	 * 事件处理
	 *-----------------------------------------------------------------------------------*/
	// onClick
	onClick = (e)=> {

	}
    
    // onRedirect
    onRedirect = (url, e)=> {
        wx.redirectTo({
            url: url
        })
    }

    // onNavigate
    onNavigate = (url, e)=> {

    }

	/*------------------------------------------------------------------------------------
	 * 自定义方法
	 *-----------------------------------------------------------------------------------*/

    getUserInfo(e) {
		wx.login({
			success: res => {
			  DoHttp.Cget({
				url:'he_rushbuy/worker/getopenid.php',
				data:{
				  js_code:res.code
				},
				success:(res) => {
				},
				error(res){
					let openid = res.openid;
					DoHttp.Login(openid, e.detail.userInfo);
				}
			  })
			}
		})
		

	}



	config = {
        navigationBarTitleText: '认证微信身份',
        navigationBarBackgroundColor: '#dd2f3c',
        navigationBarTextStyle: '#fff'
    }

	/*------------------------------------------------------------------------------------
	 * 渲染
	 *-----------------------------------------------------------------------------------*/
	render () {
		return (
			<CPage>
				<CContent style="background:#F7F7F7">
					<Button openType="getUserInfo" onGetUserInfo={this.getUserInfo}>认证微信个人信息</Button>
				</CContent>
			</CPage>
		)
	}
}


